﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAccessLayer.Helper
{
    public class DeleteText : CommandGenerationBehaviour
    {
        public override string[] SetBaseCommandParameters()
        {
            return new string[] { m_InputObject.SchemaName(), m_InputObject.BaseClassName(), (m_BaseObject.PrimaryKey()) };
        }

        public override string[] SetDerivedCommandParameters()
        {
            return new string[] { m_InputObject.SchemaName(), m_InputObject.GetTableName(), m_InputObject.PrimaryKey() };
        }

        public override Dictionary<int, string> PopulateDictionaryCommandText(string baseClassCommand, string derivedComm)
        {
            Dictionary<int, string> dict = new Dictionary<int, string>();

            if (!string.IsNullOrEmpty(baseClassCommand))
                dict.Add(2, baseClassCommand);
            else
                dict.Add(1, derivedComm);

            if (!string.IsNullOrEmpty(baseClassCommand))
                dict.Add(1, derivedComm);

            return dict;
        }

        public override string GetSpecializedCommandText(params string[] input)
        {
            return string.Format("DELETE {0}.{1} WHERE Id={2}", input[0], input[1], input[2]);
        }
    }
}
